<div class="modal fade" id="j-authority-pop">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">角色设置</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal">
                    <div class="box-body">
                        <div class="row">
                            <div class="col-sm-10"></div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2"><label style="line-height: 35px;">角色选择:</label></div>
                            <div class="col-sm-8 j-select-role">

                            </div>
                        </div>
                    </div>

                    <div class="box-footer">
                        <div class="pull-right">
                            <button type="button" class="btn btn-info j-save-userrole">确定</button>
                            &nbsp;&nbsp;&nbsp;&nbsp;<button type="button" class="btn btn-default pull-right" data-dismiss="modal">取消</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    function editAuthority(id){
        $.ajax({
            url:'${request.contextPath}/role/',
            type:'get',
            headers:{
                Accept:"application/json"
            },
            data:{userid:id},
            contentType:'application/json',
            success:function(result){
                var ur = result.msg.userRole;
                var html = '<select class="form-control" data-userId = "'+id+'">';
                $.each(result.msg.role,function(i,item){
                    if(ur !=null && ur.role.id == item.id ){
                        html += '<option value="'+item.id+'" selected>'+item.name+'</option>'
                    }else {
                        html += '<option value="'+item.id+'" >'+item.name+'</option>'
                    }

                });
                html += '</select>';
                $('#j-authority-pop .j-select-role').empty().append(html);
                $("#j-authority-pop").modal('show');
            }
        });
    }
</script>